using System.Collections.Generic;
using System.IO;

namespace Codemo.Core.Applications
{
    /// <summary>
    /// 
    /// </summary>
    public class PackageRepository
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PackageRepository"/> class.
        /// </summary>
        /// <param name="path">The path.</param>
        public PackageRepository(string path)
        {
            Directory = new DirectoryInfo(path);
        }

        /// <summary>
        /// Gets or sets the directory.
        /// </summary>
        /// <value>The directory.</value>
        public DirectoryInfo Directory { get; private set; }

        /// <summary>
        /// Gets the packages.
        /// </summary>
        /// <value>The packages.</value>
        public IList<Package> Packages
        {
            get
            {
                IList<Package> packages = new List<Package>();

                foreach (DirectoryInfo directoryInfo in Directory.GetDirectories())
                {
                    packages.Add(new Package(directoryInfo.Name, directoryInfo.FullName));
                }
                return packages;
            }
        }
    }
}